<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>translate实现垂直居中</title>
    <style>
      * {
        padding: 0;
        margin: 0;
      }
      #father {
        position: relative;
        height: 500px;
        background-color: green;
      }
      #son {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 100px;
        height: 100px;
        background-color: orange;
        transform: translate(-50%, -50%);
      }
    </style>
  </head>
  <body>
    <div id="father">
      <div id="son"></div>
    </div>
  </body>
</html>
